home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -websites- / wirenet / files / thor25_arexx.lha / Examples / ListFiles.br < prev    next >
Text File  |  1995-09-06  |  2KB  |  126 lines

  1. /*  ListFiles.br
  2.  *
  3.  *  Arexx script to list all files on a bbs
  4.  *
  5.  *  Script by: Eivind Nordseth, Ultima Thule Software.
  6.  */
  7.     options results
  8. /*    trace results */
  9.  
  10.     parse arg argument
  11.     template = 'BBSNAME/A,FAREANAME'
  12.  
  13.     if(argument = '' | argument = '?') then
  14.     do
  15.         say '$VER: ListFiles.br 3.4 (12.09.94)'
  16.         say 'Template:' template
  17.         exit
  18.     end
  19.  
  20.     if ~show('p', 'BBSREAD') then do
  21.         address command
  22.             "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  23.             "WaitForPort BBSREAD"
  24.     end
  25.  
  26.     address BBSREAD
  27.     
  28.     rc = 0
  29.     signal on ERROR 
  30.  
  31.     READARGS template ARGS CMDLINE argument
  32.     if(rc ~= 0) then 
  33.     do
  34.         say BBSREAD.LASTERROR
  35.         exit
  36.     end
  37.     
  38.     if(symbol("ARGS.FAREANAME") = "VAR") then
  39.     do
  40.         call showfilearea('"' || ARGS.BBSNAME || '"', '"' || ARGS.FAREANAME || '"')
  41.     end
  42.     else
  43.     do
  44.         GETFAREALIST ARGS.BBSNAME FAREAS
  45.  
  46.         do i=1 to FAREAS.COUNT
  47.             call showfilearea('"' || ARGS.BBSNAME || '"', '"' || FAREAS.i || '"') 
  48.         end
  49.     end
  50.  
  51.     exit
  52.  
  53.  
  54. /* Procedure to show the files in a file area */
  55.  
  56. showfilearea: procedure 
  57.     parse arg bbs,farea
  58.  
  59.     GETFAREADATA bbs farea FAREADATA
  60.  
  61.     say '0a'x || '(' || strip(farea,B,'"') || ')'
  62.     nextfile = FAREADATA.FIRSTFILE
  63.  
  64.     do until nextfile = 0
  65.         nextfile = showfiledata(bbs, farea, nextfile)
  66.     end
  67.  
  68.     return
  69.  
  70.     
  71.  
  72. /* Procedure to show the data about a file */
  73.  
  74. showfiledata: procedure
  75.     parse arg bbs,farea,filenr
  76.  
  77.     FDF_DELETED = '00000001'x
  78.  
  79.     drop FILE.    /* Important */
  80.  
  81.     READBRFILE bbs farea filenr tagsstem FILE datastem DATA
  82.  
  83.     nextfile = result
  84.  
  85.     if (bitand(DATA.FLAGS,FDF_DELETED) ~= FDF_DELETED) then
  86.     do
  87.         if(symbol("FILE.DATE") = "VAR") then fdate = FILE.DATE
  88.         else fdate = DATA.FILEDATE
  89.     
  90.         AMIGA2DATE fdate CD
  91.         fdatestr = right(CD.YEAR, 2) || right('0'||CD.MONTH, 2) || right('0'||CD.MDAY, 2)
  92.  
  93.         if(symbol("FILE.SIZE") = "VAR") then fsize = FILE.SIZE
  94.         else fsize = "Unkn"
  95.                 
  96.         if(symbol("FILE.DOWNLOADS") = "VAR") then fdnls = FILE.DOWNLOADS
  97.         else fdnls = "Unkn"
  98.                 
  99.         if(symbol("FILE.DESCRIPTION.COUNT") = "VAR") then descr = FILE.DESCRIPTION.1
  100.         else descr = "NONE"
  101.  
  102.         say left(FILE.NAME,16) || " " || fdatestr || " " || right(fsize,7) || right(fdnls,4) || " " || descr
  103.     
  104.         if(descr ~= "NONE") then 
  105.         do
  106.             if(FILE.DESCRIPTION.COUNT > 1) then
  107.             do
  108.                 do n=2 to FILE.DESCRIPTION.COUNT
  109.                     say left("",37) || FILE.DESCRIPTION.n
  110.                 end
  111.             end
  112.         end
  113.     end
  114.     else say 'File is deleted'
  115.  
  116.     return nextfile
  117.  
  118.  
  119. ERROR:
  120.     if(rc ~= 0) then 
  121.     do
  122.         say 'Error' rc 'in line' SIGL ':' BBSREAD.LASTERROR
  123.         exit
  124.     end
  125.     exit
  126.